# -*- encoding: utf-8 -*-
'''
@文件    :romantoint.py
@说明    :
@时间    :2020/05/26 16:28:37
@作者    :张钧铭
'''

class Solution(object):
    def romanToInt(self, s):
        # '''
        # :type s: str
        # :rtype: int
        # '''
        res=0

        fournight = {'IV':'4+','IX':'9+','XL':'40+','XC':'90+','CD':'400+','CM':'900+'}
        for key,value in fournight.items():
            s=s.replace(key,value)
        others = {'I':'1+',
                  'V':'5+',
                  'X':'10+',
                  'L':'50+',
                  'C':'100+',
                  'D':'500+',
                  'M':'1000+'}
        for key,value in others.items():
            s=s.replace(key,value)
  
        res = eval(s[:-1])
        return res
ss=Solution()
result = ss.romanToInt('MCMXCIV')